public class Statement {
	
	private Assigner asgnmt;
	private Conditions i;
	private Whiles lp;
	private PloInput inp;
	private PloOutput outp;

	public Statement(Tokens tokens) {
		this.asgnmt = null;
		this.i = null;
		this.lp = null;
		this.inp = null;
		this.outp = null;
		this.parse(tokens);
	}
	
	private void parse(Tokens tokens){
		if(tokens.getToken() == 32){ //if statement is an assignment
			this.asgnmt = new Assigner(tokens);
		} else if(tokens.getToken() == 5){ // if statement is an if statement
			this.i = new Conditions(tokens);		
		} else if(tokens.getToken() == 8){ // if statement is a while loop
			this.lp = new Whiles(tokens);
		} else if(tokens.getToken() == 10){ // if statement is a read command
			this.inp = new PloInput(tokens);
		} else if(tokens.getToken() == 11){ // if statement is a write command
			this.outp = new PloOutput(tokens);
		} else {
			System.err.println("Invalid Statement declaration at token: " + tokens.idName());
			System.exit(0);
		}
	}

	public void runStmt() {
		if(this.asgnmt != null){
			this.asgnmt.runAssign();
		} else if(this.i != null){
			this.i.runIf();
		} else if (this.lp != null){
			this.lp.runLoop();
		} else if(inp != null){
			this.inp.runInput();
		} else if(outp != null){
			this.outp.runOutput();
		}
	}
}